﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.SqlClient;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;
using ERP_RORZE_TOOL.Tool.Reports;
using ERP_RORZE_TOOL.BizLogic;
using ERP_RORZE_TOOL.Common;
using ERP_RORZE_TOOL.Common.ValueObject;

namespace ERP_RORZE_TOOL.Tool.UserControls
{
	public partial class uc_rpt_Tool : DevExpress.XtraEditors.XtraUserControl
	{
        ReportHelper helper = new ReportHelper();
       // public string header;

		public uc_rpt_Tool(int reportName, string header)
		{
			InitializeComponent();
			//Add();
		    switch (reportName)
		    {
                case ToolConstants.Configuration.ReportName.FImportDetails:
                    FImportDetails rp1 = new FImportDetails(header);
                    rp1.DataSource = GetData(reportName);
                    docViewerToolInStock.DocumentSource = rp1;
                    break;
                case ToolConstants.Configuration.ReportName.FMonthlyImport:
                    FMonthlyImport rp2 = new FMonthlyImport(header);
                    rp2.DataSource = GetData(reportName);
                    docViewerToolInStock.DocumentSource = rp2;
                    break;
                case ToolConstants.Configuration.ReportName.FUseDetails:
                    FUseDetails rp3 = new FUseDetails(header);
                    rp3.DataSource = GetData(reportName);
                    docViewerToolInStock.DocumentSource = rp3;
                    break;
                case ToolConstants.Configuration.ReportName.FNewOldDetails:
                    FNewOldDetails rp4 = new FNewOldDetails(header);
                    rp4.DataSource = GetData(reportName);
                    docViewerToolInStock.DocumentSource = rp4;
                    break;
                case ToolConstants.Configuration.ReportName.FBorrowDetails:
                    FBorrowDetails rp5 = new FBorrowDetails(header);
                    rp5.DataSource = GetData(reportName);
                    docViewerToolInStock.DocumentSource = rp5;
                    break;
                case ToolConstants.Configuration.ReportName.FTotalMachineAtFactoryBorrowAtPresent:
                    FTotalMachineAtFactoryBorrowAtPresent rp6 = new FTotalMachineAtFactoryBorrowAtPresent(header);
                    rp6.DataSource = GetData(reportName);
                    docViewerToolInStock.DocumentSource = rp6;
                    break;
                case ToolConstants.Configuration.ReportName.FTotalMachineAtFactoryBorrow:
                    FQTotalMachineAtFactoryBorrow rp8 = new FQTotalMachineAtFactoryBorrow(header);
                    rp8.DataSource = GetData(reportName);
                    docViewerToolInStock.DocumentSource = rp8;
                    break;
                case ToolConstants.Configuration.ReportName.FReturnDetails:
                    FReturnDetails rp10 = new FReturnDetails(header);
                    rp10.DataSource = GetData(reportName);
                    docViewerToolInStock.DocumentSource = rp10;
                    break;
                case ToolConstants.Configuration.ReportName.QTotalInstock1:
                    QTotalInstock1 rp11 = new QTotalInstock1(header);
                    rp11.DataSource = GetData(reportName);
                    docViewerToolInStock.DocumentSource = rp11;
                    break;
                case ToolConstants.Configuration.ReportName.QTotalInStockAtPresent:
                    QTotalInStockAtPresent rp12 = new QTotalInStockAtPresent(header);
                    rp12.DataSource = GetData(reportName);
                    docViewerToolInStock.DocumentSource = rp12;
                    break;
		    }
            

		}

        private DataSet GetData(int reportName)
		{
            DataSet ds = new DataSet();
            switch (reportName)
		    {
                case ToolConstants.Configuration.ReportName.FImportDetails:
                ds = helper.GetAllDS(ToolConstants.StoreProcedure.Report.FImportDetails);
                break;

                case ToolConstants.Configuration.ReportName.FUseDetails:
                ds = helper.GetAllDS(ToolConstants.StoreProcedure.Report.FUseDetails);
                break;

                case ToolConstants.Configuration.ReportName.FNewOldDetails:
                ds = helper.GetAllDS(ToolConstants.StoreProcedure.Report.FNewOldDetails);
                break;

                case ToolConstants.Configuration.ReportName.FBorrowDetails:
                ds = helper.GetAllDS(ToolConstants.StoreProcedure.Report.FBorrowDetails);
                break;

                case ToolConstants.Configuration.ReportName.FTotalMachineAtFactoryBorrowAtPresent:
                ds = helper.GetAllDS(ToolConstants.StoreProcedure.Report.FTotalMachineAtFactory_BorrowAtPresent);
                break;

                case ToolConstants.Configuration.ReportName.QTotalInstock1:
                ds = helper.GetAllDS(ToolConstants.StoreProcedure.Report.QTotalInstock1);
                break;

                case ToolConstants.Configuration.ReportName.FTotalMachineAtFactoryBorrow:
                ds = helper.GetAllDS(ToolConstants.StoreProcedure.Report.FQTotalMachineAtFactory_Borrow);
                break;

                case ToolConstants.Configuration.ReportName.FReturnDetails:
                ds = helper.GetAllDS(ToolConstants.StoreProcedure.Report.FReturnDetails);
                break;

                case ToolConstants.Configuration.ReportName.FMonthlyImport:
                ds = helper.GetAllDS(ToolConstants.StoreProcedure.Report.FMonthlyImport);
                break;

                case ToolConstants.Configuration.ReportName.QTotalInStockAtPresent:
                ds = helper.GetAllDS(ToolConstants.StoreProcedure.Report.QTotalInStockAtPresent);
                break;
            }

            return ds;
		}


		private void Add()
		{
			var source = new List<string>();
			for(var i = 0; i < 10; i++)
				source.Add(i.ToString());
		}


	}
}
